/*
 * @Descripttion: 处理用户接口的路由 
 * @version: 
 * @Author: 一氧化二氢
 * @Date: 2022-01-01 20:48:06
 * @lastEditorTime: Do no edit
 */

const Router = require("koa-router")

const { userValidator, verifyUser, cryptPassword, verifyLogin } = require('../middleware/user.middleware')
//导入中间件
const { auth } = require('../middleware/auth.middleware')
//  导入controller文件
const { register, login, changePassword } = require('../controller/user.controller')
//  实例化接口
const router = new Router({ prefix: '/users' })  //设置前缀

//  注册接口 userValidator,verifyUser为验证器，验证通过后才执行下面的操作
router.post('/register', userValidator, verifyUser, cryptPassword, register)

// 登录接口
router.post('/login', userValidator, verifyLogin, login)

//修改密码接口
router.patch("/", auth, cryptPassword, changePassword)

module.exports = router
